<template>
  <div class="newsinfo-container">
    <h1 class="title">
      {{ newsInfo.title }}
    </h1>
    <p class="newsinfo-nav">
      <span>发表时间:{{ newsInfo.add_time }}</span>
      <span>点击:{{ newsInfo.click }}次</span>
    </p>
    <div class="content" v-html="newsInfo.content">
      <!-- info里的 content 作为内容 -->
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      newsInfo: {},
    };
  },
  props: ["id"],
  created() {
    this.getNewsInfo();
  },

  methods: {
    getNewsInfo() {
      //   console.log(this.id);
      // 发送请求根据新闻id 获取到新闻的详细
      this.$http.get("news/show", { params: { id: this.id } }).then((res) => {
        if (res.data.status === 0) {
          this.newsInfo = res.data.message[0];
          console.log(this.newsInfo);
        } else {
          this.$toast("加载失败");
        }
      });
    },
  },
};
</script>

 
<style lang="scss">
.newsinfo-container {
  padding: 0 5px;
  .title {
    font-size: 16px;
    text-align: center;
    margin: 10px 0;
    color: orangered;
  }
  .newsinfo-nav {
    display: flex;
    justify-content: space-between;
    color: #26a2ff;
  }
  .content {
    img {
      width: 100%;
    }
  }
}
</style>